#ifndef SERVER_H
#define SERVER_H
#include<QTcpServer>
#include<QTcpSocket>


class Server :public QObject
{
    Q_OBJECT
public:
    Server(QObject *parent=0);
    ~Server();
    void init(QString ip,int port);
    void sendData(QString ip,QString data);
    void sendData(QString ip,uchar *rawData);
    void sendData(QString ip,char *data,int len);
    void closeServer();

private slots:
    void newConnectSlot();
    void readMessage();
    void removeUserFromList();
signals:
    void signal_recv_data(QString ip,QByteArray byte);
    void signal_socket_change(QString ip,bool isConn);
private:

    QTcpServer *m_tcpServer;
    QMap<QString ,QTcpSocket *> m_mapClient;
};

#endif // SERVER_H
